import sqlite

def createTable(dict, name, cur):
	print "Creating a table named ", name
	print "It will have these characteristics:"
	for item in dict:
		print item, " - ", dict[item]
	tablesql = "CREATE TABLE "+name+"("
	for item in dict:
		tablesql = tablesql + item + " " + dict[item] + ","
	tablesql = tablesql.rstrip(",")
	tablesql = tablesql + ")"
	try:
		cur.execute(tablesql)
	except:
		print "Looks like that won't work."
	return cur

if __name__ == "__main__":
	name = raw_input("What is the name of the database? ")
	roomdict = {'id':'integer PRIMARY KEY AUTOINCREMENT',
			'name':'text',
			'desc':'text',
			'northof':'integer',
			'southof':'integer',
			'eastof':'integer',
			'westof':'integer'}
	roomname = "rooms"
	
	itemsdict = {'id': 'integer PRIMARY KEY AUTOINCREMENT',
			'name': 'text',
			'desc': 'text',
			'plural': 'boolean',
			'location': 'integer'}
	itemsname = "items"

        invdict = {'item':'integer',
			'player': 'integer'}
        invname = "inventory"

        playerdict = {'id': 'integer PRIMARY KEY AUTOINCREMENT',
                        'name':'text',
			'location':'integer'}
        playername = "players"

	con = sqlite.connect(name, autocommit = 1)
	cur = con.cursor()
	
	createTable(roomdict, roomname, cur)
	createTable(itemsdict, itemsname, cur)
	createTable(invdict, invname, cur)
	con.close()
